package Util;

import java.sql.*;

/**
 * JDBC 操作工具类
 * Created by zhengbinMac on 2017/7/1.
 */
public class JdbcUtil {
    static {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    public static Connection getConnection() throws SQLException {
        return DriverManager.getConnection("jdbc:mysql://localhost:3307/station?characterEncoding=utf-8",
                "root",
                "950906");
    }

    public static void close(Statement statement, Connection connection) throws SQLException {
        statement.close();
        connection.close();
    }

    public static void close(ResultSet resultSet, Statement statement, Connection connection) throws SQLException {
        resultSet.close();
        close(statement, connection);
    }
}
